﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace WeavelWreckingBug
{
    class Sprite
    {
        public Vector2 Position = new Vector2(0, 0);
        private Texture2D spriteTexture;
        public Rectangle size;
        private float scale = 1.0f;
        public string spriteTextureName;
        public int spriteTextureHeight;
        public int spriteTextureWidth;


        public void LoadContent(ContentManager theContentManager, string textureName)
        {
            spriteTexture = theContentManager.Load<Texture2D>(textureName);
            spriteTextureName = textureName;
            size = new Rectangle(0, 0, (int)(spriteTexture.Width * Scale), (int)(spriteTexture.Height * Scale));

            spriteTextureHeight = spriteTexture.Height;
            spriteTextureWidth = spriteTexture.Width;
        }

        public void draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(spriteTexture, Position, 
                new Rectangle(0, 0, spriteTexture.Width, spriteTexture.Height), 
                Color.White, 0.0f, Vector2.Zero, Scale, SpriteEffects.None, 0);
        }

        public float Scale
        {
            get { return scale; }
            set
            {
                scale = value;

                size = new Rectangle(0, 0, (int)(spriteTexture.Width * Scale), (int)(spriteTexture.Height * Scale));
            }
        }

        public void update(GameTime gameTime, Vector2 speed, Vector2 direction)
        {
            Position += direction * speed * (float)gameTime.ElapsedGameTime.TotalSeconds;
        }
    }
}
